package com.itheima.controller.backend.reservation;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.dto.OrderUpdateDto;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @className OrderController
 */
@RestController
@RequestMapping("/order")
@RequiredArgsConstructor
@Slf4j
public class OrderController {

    private final OrderService orderService;

    /**
     * 分页查询预约列表信息
     * @param queryPageBean 分页条件
     * @return PageResult
     */
    @PostMapping("/findPage")
    public PageResult getOrderByPage(@RequestBody QueryPageBean queryPageBean) {
        return orderService.getOrderByPage(queryPageBean);
    }

    /**
     * 修改预约状态
     * @param orderUpdateDto 预约状态
     * @return Result
     */
    @PostMapping("/update")
    public Result editOrderStatus(@RequestBody OrderUpdateDto orderUpdateDto) {
        log.info("修改预约状态：{}", orderUpdateDto);
        orderService.editOrderStatus(orderUpdateDto);
        return new Result(true, MessageConstant.EDIT_ORDERSTATUS_SUCCESS);
    }
}
